/* param keys: Array
  * keys: 需要检查的key集合
  */
export function checkFormData(formData, option = { keys: [], debug: false }) {
  const keys = option.keys || []
  const debug = option.debug || false
  for (let key in formData) {
    const val = formData[key];
    if (val === null || val === undefined || val === '') {
      if (debug) { console.warn(`[KEY: ${key}] Invalidate form data`) }
      return false;
    }
    if (keys.length && !keys.includes(key)) {
      if (debug) { console.warn(`[KEY: ${key}] Invalidate form data`) }
      return false;
    }
    if (typeof val === 'object' && val !== null) {
      if (!checkFormData(val, { keys, debug })) {
        return false;
      }
    }
  }
  return true;
}
